package com.wbs.rest.config;


import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;

public class SqlMappingCacher {


    private static List<Map<String, Object>> MAPPING_DATA = new CopyOnWriteArrayList();


    public static boolean add(Map<String, Object> item){
        return MAPPING_DATA.add(item);
    }


    public static boolean reset(List<Map<String, Object>> list){

        List<Map<String, Object>> tmp = new CopyOnWriteArrayList(list);
        MAPPING_DATA = tmp;

        return true;
    }


    public static Map<String, Object> getMappingByUri(String mappingUri){
        return MAPPING_DATA.stream().filter(item -> mappingUri.equals(item.get("mapping_uri"))).findFirst().orElse(null);
    }

}
